<template>
	<view class="content">
		<view class="nav-part-bg"></view>
		<view class="body">
			<view class="nav-day">
				<view class="search">
					<u-search placeholder="输入路线名称" :showAction="false" :clearabled="true" shape="square" v-model="keyword"></u-search>
				</view>
			</view>
			<view class="showbody" v-if="lines.length">
				<view @click="selectCar(item)" class="header" v-for="(item, index) in lines" :key="index">
					<view class="row">
						<view class="line">
							<u-tag :text="'线路：' + item.name"></u-tag>
						</view>
						<view class="row-tip">
							<view class="cell">
								<text class="cell-title">简称：</text>
								<text class="cell-content">{{ item.code }}</text>
							</view>
							<view class="cell">
								<text class="cell-title">备注：</text>
								<text class="cell-content">{{ item.remark }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<empty class="showbody" v-else text="查无数据"></empty>
		</view>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
import selectDay from '@/components/selectDay.vue';
import empty from '@/components/empty.vue';
import routelistjs from '@/api/routelist.js';
import common from '@/utils/common.js';
export default {
	components: { selectDay, empty },
	computed: { ...mapGetters(['token']) },
	async onLoad(option) {
		// #ifdef MP
		//未登录转登录页面，已登录转主页面
		if (!this.$store.dispatch('checkIndentity')) return;
		// #endif
		this.initPage();
	},
	data() {
		return {
			lines: []
		};
	},
	methods: {
		async initPage() {
			//初始加载路线数据
			let res = await routelistjs.getLineData(this.token);
			if (common.httpIsWrong(res)) return;
			this.lines = res.json.data.data;
		},
		selectCar(item) {
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			prevPage.$vm.lineID = item.id;
			prevPage.$vm.lineName = item.name;
			uni.navigateBack({
				delta: 1
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: white;
	.nav-part-bg {
		width: 100%;
		height: 100rpx;
		background-color: #1a90e4;
		position: fixed;
		top: 0;
		z-index: 0;
	}
	.body {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		.nav-day {
			width: 100%;
			height: 100rpx;
			color: white;
			background-color: #1a90e4;
			position: fixed;
			top: var(--window-top, 0);
			z-index: 99;
			.search {
				margin: 0 20rpx;
			}
		}
		.showbody {
			margin-top: 100rpx;
			z-index: 1;
			.header {
				width: 100%;
				height: auto;
				box-shadow: 0px 1px 5px #d9d9d9;
				background-color: white;
				.row {
					margin: 20rpx 20rpx 0 20rpx;
					align-items: center;
					border: solid 1rpx #3c9cff;
					border-radius: 10rpx;
					background-color: #f1f2f4;
					.line {
						width: 100%;
						position: relative;
					}
					.row-tip {
						margin: 10rpx 20rpx;
						display: flex;
						flex-direction: column;
						.tip-m {
							color: #3c9cff;
						}
						.cell {
							padding: 10rpx 0;
							display: flex;
							.cell-title {
								letter-spacing: 10rpx;
								font-size: 28rpx;
								width: 120rpx;
							}
							.cell-content {
								letter-spacing: 10rpx;
								font-size: 28rpx;
								color: #1a90e4;
								flex: 1;
							}
							.cell-content2 {
								font-size: 28rpx;
								color: #1a90e4;
								margin: 0 20rpx;
							}
							.cell-row-left {
								width: 40%;
							}
							.cell-row-right {
								flex: 1;
							}
							.cell-row {
								width: 50%;
							}
						}
					}
				}
			}
			.footer {
				margin: 20rpx 20rpx;
				border-radius: 10rpx;
				background-color: white;
				box-shadow: 0px 1px 5px #888888;
				.step-spot {
					display: flex;
					flex-direction: column;
					.foot-head {
						height: 80rpx;
						display: flex;
						align-items: center;
						padding-left: 30rpx;
					}
					.foot-tip {
						background-color: #e8f2fe;
						border-radius: 0 0 10rpx 10rpx;
						.row-tip {
							margin: 10rpx 20rpx;
							display: flex;
							flex-direction: column;
							.tip-m {
								color: #3c9cff;
							}
							.cell {
								padding: 10rpx 0;
								display: flex;
								.cell-title {
									letter-spacing: 10rpx;
									font-size: 28rpx;
								}
								.cell-content {
									flex: 1;
									letter-spacing: 10rpx;
									font-size: 28rpx;
									color: #1a90e4;
									margin: 0 20rpx;
								}
								.cell-content2 {
									font-size: 28rpx;
									color: #1a90e4;
									margin: 0 20rpx;
								}
								.cell-row-left {
									width: 50%;
								}
								.cell-row-right {
									flex: 1;
								}
								.cell-row {
									width: 50%;
								}
							}
						}
					}
					.collapse {
						width: 100%;
					}
					.step {
						display: flex;
						flex-direction: column;
						.cellbody {
							padding: 10rpx 0;
							display: flex;
							.cellbody-title {
								letter-spacing: 4rpx;
								font-size: 28rpx;
							}
							.cellbody-content {
								font-size: 28rpx;
								letter-spacing: 4rpx;
								color: #1a90e4;
								margin: 0 20rpx;
							}
							.cellbody-content2 {
								font-size: 28rpx;
								letter-spacing: 4rpx;
								color: #1a90e4;
								margin: 0 20rpx;
							}
							.cellbody-row-left {
								width: 50%;
							}
							.cellbody-row-right {
								flex: 1;
							}
							.cellbody-row {
								width: 50%;
							}
						}
					}
				}
			}
		}
	}
}
::v-deep .u-steps.u-steps--column {
	width: 100%;
}
</style>
